package com.ruoyi.rocky.enums;

import java.util.Arrays;
import java.util.Optional;

public enum OrderStatus {

    UNPAID("daiZhiFu", "待支付"),
    WAITDELIVER("daiFa", "待发货"),
    INTRANSIT("peiSong", "配送中"),
    COMPLETED("wanCheng", "已完成"),
    CANCEL("quXiao", "取消订单");

    private String code;
    private String desc;

    public static OrderStatus findByCode(Integer code) {
        Optional<OrderStatus> first = Arrays.stream(OrderStatus.values()).filter(item -> item.getCode().equals(code)).findFirst();
        return first.orElse(null);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    OrderStatus(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

}
